package com.example.anew.journey.mynewjourney.firstchangelogic.FirstChangeSetting.model;

import android.content.Context;
import android.content.SharedPreferences;

import com.example.anew.journey.mynewjourney.bean.TakeDateBean;

import static android.content.Context.MODE_PRIVATE;

/**
 * 杭州惟君医疗科技有限公司13
 * Created by 20433 on 2018/3/29
 *
 * @desc 东风山河绿，春已不折柳，繁花看不尽，处处惹人留
 * @desc 佛祖镇楼，bug辟容易
 */

public class FirstChangeSettingModel implements ISFirstChangeSettingModel{
    @Override
    public TakeDateBean TakeDate(Context mContext) {
        SharedPreferences sharedPreferences = mContext.getSharedPreferences("My_App_Cardiac", MODE_PRIVATE);
        String my_use_id = sharedPreferences.getString("my_use_id", "");
        String my_use_token = sharedPreferences.getString("my_use_token", "");
        TakeDateBean takeDateBean =  new TakeDateBean();
        takeDateBean.setUser_id(my_use_id);
        takeDateBean.setToken(my_use_token);
        return takeDateBean;
    }

    @Override
    public void clear(Context mContext) {
        //获取一个文件名为test、权限为private的xml文件的SharedPreferences对象
        SharedPreferences sharedPreferences = mContext.getSharedPreferences("My_App_Cardiac", MODE_PRIVATE);
        //得到SharedPreferences.Editor对象，并保存数据到该对象中
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString("my_use_id", "");
        editor.putString("my_use_name", "");
        editor.putString("my_use_tel", "");
        editor.putString("my_use_logo","");
        editor.putString("my_use_birthday", "");
        editor.putString("my_use_state", "");
        editor.putString("my_use_qq", "");
        editor.putString("my_use_weixin", "");
        editor.putString("my_use_token", "");

        editor.putString("my_use_join_date", "");
        editor.putString("my_use_token", "");
        editor.putBoolean("my_is_login",false);
        editor.putInt("my_stored_data_number",0);
        //保存key-value对到文件中
        editor.commit();
    }
}
